class Solution
{
public:
    int halveArray(vector<int> &nums)
    {
        priority_queue<double> q;
        double sum = 0.0;
        for (int num : nums)
        {
            sum += num;
            q.push(num);
        }
        double decreased = 0.0;
        int opCount = 0;
        while (decreased * 2 < sum)
        {
            double maxNum = q.top();
            q.pop();
            decreased += maxNum / 2;
            q.push(maxNum / 2);
            ++opCount;
        }
        return opCount;
    }
};